#ifndef CMD_UART_H
#define CMD_UART_H


/******************************************************************************
 Macro
 *****************************************************************************/
// A5 5A LEN PAYLOAD CRC16
#define CMD_UART_BUF_SIZE      32

#define CMD_STATE_IDLE         0
#define CMD_STATE_START        1
#define CMD_STATE_DATA         2
#define CMD_STATE_ERRO         3

#define CMD_EVT_RX_TIMEOUT     MFG_CMD_RX_EVENT
#define CMD_EVT_TX_TRIGGER     MFG_CMD_TX_EVENT

#define CMD_CRC_INIT         0xFFFF
#define CMD_ACK_MAX_LEN      128

typedef struct
{
  osal_event_hdr_t hdr;
  uint8 size;
  uint8 data[];
}cmd_uartRxMsg_t;

void cmd_uartInit(uint8 taskId);
void cmd_uartRxProcess(uint8 size, uint8* data);
void cmd_uartRxTimeout(void);
void cmd_UartTxTrigger(void);
bool cmd_UartTxSend(uint8 len, uint8 *payload);
bool cmd_UartAckSend(uint8 cmdSeq, uint8 cmdClass, uint8 len, uint8* extData);
uint8 cmd_UartGetSeqNum(void);
void cmd_UartErroWarning(uint8 erro);

#endif
